package com.example.j2025_11_10.controller;

import jakarta.servlet.http.HttpSession;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {
    @RequestMapping("/login")
    public Boolean login(String name, String password, HttpSession session){
        //密码校验
        if(!StringUtils.hasLength(name) || !StringUtils.hasLength(password)){
            return false;
        }
        //对密码校验
        if ("admin".equals(name) && "admin".equals(password)){
            session.setAttribute("username",name);
            return true;
        }
        //密码错误
        return false;
    }

}
